<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>上传图片处理</title>
</head>
<body>
    <img width="400" src="" alt="">
    <input id="upload" type="file" name="uploadImg" />

<script src="dish/imageProcess.js"></script>
<script>
    var inp = document.getElementById('upload');
    inp.addEventListener('change', function(e){
        let file = this.files[0],
            imageProcess = new ImageProcess({
                compress: {
                    format: 'file'
                }
            });
        console.log('upload:', file);
        imageProcess.compress(file).then(res => {
            console.log('压缩后:', res);
            let img = document.querySelector('img');
            img.src = URL.createObjectURL(res);
            // img.src = res;
        })
    });
</script>
</body>
</html>